//环境配置，方便切换不同运行环境
const envs = [
  {env:'prod', isHttps:true, domain:'bat.prod.chainteam.cc'},
  {env:'pre', isHttps:false, domain:'bat-pre.chainteam.cc'},
  {env:'test', isHttps:false, domain:'bat.test.chainteam.cc'},
  {env:'dev', isHttps:false, domain:'bat.dev.chainteam.cc'},
]

let domain = process.env.NODE_ENV == 'development' ? 'bat.dev.chainteam.cc' : location.host.split(':')[0]

const protocol = location.protocol
if (protocol == 'file:' && process.env.VUE_APP_BASEURL) {
  domain = process.env.VUE_APP_BASEURL
}
let isHttps = protocol == 'https:'?true:false
if (protocol == 'file:' && process.env.VUE_APP_HTTPS=='true') {
  isHttps = true
}

//如果有固定环境配置，优先级最高
let env = localStorage.getItem('env')
env && (env=envs.find(item=>item.env==env))
if(env){
  isHttps = env.isHttps
  domain = env.domain
}

const wshttp = isHttps ? 'wss://': 'ws://'
const http = isHttps ? 'https://' : 'http://'

const config = {
  envs,
  domain,
  http,
  wshttp,
  url: `${http}${domain}`,
  imageType: /\.(jpg|png|jpeg|bmp)/i,
  invasion: true, //控制App webview是否嵌入式显示
  headUrl: `${http}${domain}/res/`,
  brand: 'VTX',
  updateInfo:{  //更新日志
    'zh-CN':`
    <div>1. 优化页面</div>
    <div>2. 修复BUG</div>
    `,
    'zh-TW':`
    <div>1. 優化頁面</div>
    <div>2. 修復BUG</div>
    `,
    'en-US':`
    <div>1. Optimize app pages</div>
    <div>2. Fix bug</div>
    `
  }
}

export default config
